home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: LaTeX Document
(document/latex).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| LaTeX Document (document/latex)
| magic
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| LaTeX document text
| default
| |
99%
| file
| HTML document text
| default (weak)
| |
98%
| file
| LaTeX document, ASCII text, with CR line terminators
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/281 LaTeX (Subdocument)
| default
| |
100%
| detectItEasy
| Format: plain text[CR]
| default (weak)
|
|
id metadata |
---|
key | value |
---|
macFileType | [TEXT] |
macFileCreator | [R*ch] |
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 73 65 63 74 69 6f 6e | 7b 53 74 61 6e 64 61 72 |\section|{Standar|
|00000010| 64 20 4d 6f 64 75 6c 65 | 20 5c 73 65 63 74 63 6f |d Module| \sectco|
|00000020| 64 65 7b 63 67 69 7d 7d | 0d 5c 73 74 6d 6f 64 69 |de{cgi}}|.\stmodi|
|00000030| 6e 64 65 78 7b 63 67 69 | 7d 0d 5c 69 6e 64 65 78 |ndex{cgi|}.\index|
|00000040| 69 69 7b 57 57 57 7d 7b | 73 65 72 76 65 72 7d 0d |ii{WWW}{|server}.|
|00000050| 5c 69 6e 64 65 78 69 69 | 7b 43 47 49 7d 7b 70 72 |\indexii|{CGI}{pr|
|00000060| 6f 74 6f 63 6f 6c 7d 0d | 5c 69 6e 64 65 78 69 69 |otocol}.|\indexii|
|00000070| 7b 48 54 54 50 7d 7b 70 | 72 6f 74 6f 63 6f 6c 7d |{HTTP}{p|rotocol}|
|00000080| 0d 5c 69 6e 64 65 78 69 | 69 7b 4d 49 4d 45 7d 7b |.\indexi|i{MIME}{|
|00000090| 68 65 61 64 65 72 73 7d | 0d 5c 69 6e 64 65 78 7b |headers}|.\index{|
|000000a0| 55 52 4c 7d 0d 0d 5c 72 | 65 6e 65 77 63 6f 6d 6d |URL}..\r|enewcomm|
|000000b0| 61 6e 64 7b 5c 69 6e 64 | 65 78 73 75 62 69 74 65 |and{\ind|exsubite|
|000000c0| 6d 7d 7b 28 69 6e 20 6d | 6f 64 75 6c 65 20 63 67 |m}{(in m|odule cg|
|000000d0| 69 29 7d 0d 0d 54 68 69 | 73 20 6d 6f 64 75 6c 65 |i)}..Thi|s module|
|000000e0| 20 6d 61 6b 65 73 20 69 | 74 20 65 61 73 79 20 74 | makes i|t easy t|
|000000f0| 6f 20 77 72 69 74 65 20 | 50 79 74 68 6f 6e 20 73 |o write |Python s|
|00000100| 63 72 69 70 74 73 20 74 | 68 61 74 20 72 75 6e 20 |cripts t|hat run |
|00000110| 69 6e 20 61 20 57 57 57 | 0d 73 65 72 76 65 72 20 |in a WWW|.server |
|00000120| 75 73 69 6e 67 20 74 68 | 65 20 43 6f 6d 6d 6f 6e |using th|e Common|
|00000130| 20 47 61 74 65 77 61 79 | 20 49 6e 74 65 72 66 61 | Gateway| Interfa|
|00000140| 63 65 2e 20 20 49 74 20 | 77 61 73 20 77 72 69 74 |ce. It |was writ|
|00000150| 74 65 6e 20 62 79 20 4d | 69 63 68 61 65 6c 0d 4d |ten by M|ichael.M|
|00000160| 63 4c 61 79 20 61 6e 64 | 20 73 75 62 73 65 71 75 |cLay and| subsequ|
|00000170| 65 6e 74 6c 79 20 6d 6f | 64 69 66 69 65 64 20 62 |ently mo|dified b|
|00000180| 79 20 53 74 65 76 65 20 | 4d 61 6a 65 77 73 6b 69 |y Steve |Majewski|
|00000190| 20 61 6e 64 20 47 75 69 | 64 6f 20 76 61 6e 0d 52 | and Gui|do van.R|
|000001a0| 6f 73 73 75 6d 2e 0d 0d | 57 68 65 6e 20 61 20 57 |ossum...|When a W|
|000001b0| 57 57 20 73 65 72 76 65 | 72 20 66 69 6e 64 73 20 |WW serve|r finds |
|000001c0| 74 68 61 74 20 61 20 55 | 52 4c 20 63 6f 6e 74 61 |that a U|RL conta|
|000001d0| 69 6e 73 20 61 20 72 65 | 66 65 72 65 6e 63 65 20 |ins a re|ference |
|000001e0| 74 6f 20 61 20 66 69 6c | 65 20 69 6e 20 61 0d 70 |to a fil|e in a.p|
|000001f0| 61 72 74 69 63 75 6c 61 | 72 20 73 75 62 64 69 72 |articula|r subdir|
|00000200| 65 63 74 6f 72 79 20 28 | 75 73 75 61 6c 6c 79 20 |ectory (|usually |
|00000210| 5c 63 6f 64 65 7b 2f 63 | 67 69 62 69 6e 7d 29 2c |\code{/c|gibin}),|
|00000220| 20 69 74 20 72 75 6e 73 | 20 74 68 65 20 66 69 6c | it runs| the fil|
|00000230| 65 20 61 73 0d 61 20 73 | 75 62 70 72 6f 63 65 73 |e as.a s|ubproces|
|00000240| 73 2e 20 20 49 6e 66 6f | 72 6d 61 74 69 6f 6e 20 |s. Info|rmation |
|00000250| 61 62 6f 75 74 20 74 68 | 65 20 72 65 71 75 65 73 |about th|e reques|
|00000260| 74 20 73 75 63 68 20 61 | 73 20 74 68 65 20 66 75 |t such a|s the fu|
|00000270| 6c 6c 20 55 52 4c 2c 20 | 74 68 65 0d 6f 72 69 67 |ll URL, |the.orig|
|00000280| 69 6e 61 74 69 6e 67 20 | 68 6f 73 74 20 65 74 63 |inating |host etc|
|00000290| 2e 2c 20 69 73 20 70 61 | 73 73 65 64 20 74 6f 20 |., is pa|ssed to |
|000002a0| 74 68 65 20 73 75 62 70 | 72 6f 63 65 73 73 20 69 |the subp|rocess i|
|000002b0| 6e 20 74 68 65 20 73 68 | 65 6c 6c 0d 65 6e 76 69 |n the sh|ell.envi|
|000002c0| 72 6f 6e 6d 65 6e 74 3b | 20 61 64 64 69 74 69 6f |ronment;| additio|
|000002d0| 6e 61 6c 20 69 6e 70 75 | 74 20 66 72 6f 6d 20 74 |nal inpu|t from t|
|000002e0| 68 65 20 63 6c 69 65 6e | 74 20 6d 61 79 20 62 65 |he clien|t may be|
|000002f0| 20 72 65 61 64 20 66 72 | 6f 6d 0d 73 74 61 6e 64 | read fr|om.stand|
|00000300| 61 72 64 20 69 6e 70 75 | 74 2e 20 20 53 74 61 6e |ard inpu|t. Stan|
|00000310| 64 61 72 64 20 6f 75 74 | 70 75 74 20 66 72 6f 6d |dard out|put from|
|00000320| 20 74 68 65 20 73 75 62 | 70 72 6f 63 65 73 73 20 | the sub|process |
|00000330| 69 73 20 73 65 6e 74 20 | 62 61 63 6b 0d 61 63 72 |is sent |back.acr|
|00000340| 6f 73 73 20 74 68 65 20 | 6e 65 74 77 6f 72 6b 20 |oss the |network |
|00000350| 74 6f 20 74 68 65 20 63 | 6c 69 65 6e 74 20 61 73 |to the c|lient as|
|00000360| 20 74 68 65 20 72 65 73 | 70 6f 6e 73 65 20 66 72 | the res|ponse fr|
|00000370| 6f 6d 20 74 68 65 20 72 | 65 71 75 65 73 74 2e 0d |om the r|equest..|
|00000380| 54 68 65 20 43 47 49 20 | 70 72 6f 74 6f 63 6f 6c |The CGI |protocol|
|00000390| 20 64 65 73 63 72 69 62 | 65 73 20 77 68 61 74 20 | describ|es what |
|000003a0| 74 68 65 20 65 6e 76 69 | 72 6f 6e 6d 65 6e 74 20 |the envi|ronment |
|000003b0| 76 61 72 69 61 62 6c 65 | 73 20 70 61 73 73 65 64 |variable|s passed|
|000003c0| 20 74 6f 0d 74 68 65 20 | 73 75 62 70 72 6f 63 65 | to.the |subproce|
|000003d0| 73 73 20 6d 65 61 6e 20 | 61 6e 64 20 68 6f 77 20 |ss mean |and how |
|000003e0| 74 68 65 20 6f 75 74 70 | 75 74 20 73 68 6f 75 6c |the outp|ut shoul|
|000003f0| 64 20 62 65 20 66 6f 72 | 6d 61 74 74 65 64 2e 20 |d be for|matted. |
|00000400| 20 54 68 65 0d 6f 66 66 | 69 63 69 61 6c 20 72 65 | The.off|icial re|
|00000410| 66 65 72 65 6e 63 65 20 | 64 6f 63 75 6d 65 6e 74 |ference |document|
|00000420| 61 74 69 6f 6e 20 66 6f | 72 20 74 68 65 20 43 47 |ation fo|r the CG|
|00000430| 49 20 70 72 6f 74 6f 63 | 6f 6c 20 63 61 6e 20 62 |I protoc|ol can b|
|00000440| 65 20 66 6f 75 6e 64 20 | 6f 6e 0d 74 68 65 20 57 |e found |on.the W|
|00000450| 6f 72 6c 64 2d 57 69 64 | 65 20 57 65 62 20 61 74 |orld-Wid|e Web at|
|00000460| 0d 5c 63 6f 64 65 7b 3c | 55 52 4c 3a 68 74 74 70 |.\code{<|URL:http|
|00000470| 3a 2f 2f 68 6f 6f 68 6f | 6f 2e 6e 63 73 61 2e 75 |://hooho|o.ncsa.u|
|00000480| 69 75 63 2e 65 64 75 2f | 63 67 69 2f 6f 76 65 72 |iuc.edu/|cgi/over|
|00000490| 76 69 65 77 2e 68 74 6d | 6c 3e 7d 2e 20 20 54 68 |view.htm|l>}. Th|
|000004a0| 65 0d 5c 63 6f 64 65 7b | 63 67 69 7d 20 6d 6f 64 |e.\code{|cgi} mod|
|000004b0| 75 6c 65 20 77 61 73 20 | 62 61 73 65 64 20 6f 6e |ule was |based on|
|000004c0| 20 76 65 72 73 69 6f 6e | 20 31 2e 31 20 6f 66 20 | version| 1.1 of |
|000004d0| 74 68 65 20 70 72 6f 74 | 6f 63 6f 6c 20 61 6e 64 |the prot|ocol and|
|000004e0| 20 73 68 6f 75 6c 64 0d | 61 6c 73 6f 20 77 6f 72 | should.|also wor|
|000004f0| 6b 20 77 69 74 68 20 76 | 65 72 73 69 6f 6e 20 31 |k with v|ersion 1|
|00000500| 2e 30 2e 0d 0d 54 68 65 | 20 5c 63 6f 64 65 7b 63 |.0...The| \code{c|
|00000510| 67 69 7d 20 6d 6f 64 75 | 6c 65 20 64 65 66 69 6e |gi} modu|le defin|
|00000520| 65 73 20 73 65 76 65 72 | 61 6c 20 63 6c 61 73 73 |es sever|al class|
|00000530| 65 73 20 74 68 61 74 20 | 6d 61 6b 65 20 69 74 20 |es that |make it |
|00000540| 65 61 73 79 20 74 6f 0d | 61 63 63 65 73 73 20 74 |easy to.|access t|
|00000550| 68 65 20 69 6e 66 6f 72 | 6d 61 74 69 6f 6e 20 70 |he infor|mation p|
|00000560| 61 73 73 65 64 20 74 6f | 20 74 68 65 20 73 75 62 |assed to| the sub|
|00000570| 70 72 6f 63 65 73 73 20 | 66 72 6f 6d 20 61 20 50 |process |from a P|
|00000580| 79 74 68 6f 6e 20 73 63 | 72 69 70 74 3b 0d 69 6e |ython sc|ript;.in|
|00000590| 20 70 61 72 74 69 63 75 | 6c 61 72 2c 20 69 74 20 | particu|lar, it |
|000005a0| 6b 6e 6f 77 73 20 68 6f | 77 20 74 6f 20 70 61 72 |knows ho|w to par|
|000005b0| 73 65 20 74 68 65 20 69 | 6e 70 75 74 20 73 65 6e |se the i|nput sen|
|000005c0| 74 20 62 79 20 61 6e 20 | 48 54 4d 4c 0d 60 60 66 |t by an |HTML.``f|
|000005d0| 6f 72 6d 27 27 20 75 73 | 69 6e 67 20 65 69 74 68 |orm'' us|ing eith|
|000005e0| 65 72 20 61 20 50 4f 53 | 54 20 6f 72 20 61 20 47 |er a POS|T or a G|
|000005f0| 45 54 20 72 65 71 75 65 | 73 74 20 28 74 68 65 73 |ET reque|st (thes|
|00000600| 65 20 61 72 65 20 61 6c | 74 65 72 6e 61 74 69 76 |e are al|ternativ|
|00000610| 65 73 0d 66 6f 72 20 73 | 75 62 6d 69 74 74 69 6e |es.for s|ubmittin|
|00000620| 67 20 66 6f 72 6d 73 20 | 69 6e 20 74 68 65 20 48 |g forms |in the H|
|00000630| 54 54 50 20 70 72 6f 74 | 6f 63 6f 6c 29 2e 0d 0d |TTP prot|ocol)...|
|00000640| 54 68 65 20 66 6f 72 6d | 61 74 74 69 6e 67 20 6f |The form|atting o|
|00000650| 66 20 74 68 65 20 6f 75 | 74 70 75 74 20 69 73 20 |f the ou|tput is |
|00000660| 73 6f 20 74 72 69 76 69 | 61 6c 20 74 68 61 74 20 |so trivi|al that |
|00000670| 6e 6f 20 61 64 64 69 74 | 69 6f 6e 61 6c 20 73 75 |no addit|ional su|
|00000680| 70 70 6f 72 74 0d 69 73 | 20 6e 65 65 64 65 64 2e |pport.is| needed.|
|00000690| 20 20 41 6c 6c 20 79 6f | 75 20 6e 65 65 64 20 74 | All yo|u need t|
|000006a0| 6f 20 64 6f 20 69 73 20 | 70 72 69 6e 74 20 61 20 |o do is |print a |
|000006b0| 6d 69 6e 69 6d 61 6c 20 | 73 65 74 20 6f 66 20 4d |minimal |set of M|
|000006c0| 49 4d 45 20 68 65 61 64 | 65 72 73 0d 64 65 73 63 |IME head|ers.desc|
|000006d0| 72 69 62 69 6e 67 20 74 | 68 65 20 6f 75 74 70 75 |ribing t|he outpu|
|000006e0| 74 20 66 6f 72 6d 61 74 | 2c 20 66 6f 6c 6c 6f 77 |t format|, follow|
|000006f0| 65 64 20 62 79 20 61 20 | 62 6c 61 6e 6b 20 6c 69 |ed by a |blank li|
|00000700| 6e 65 20 61 6e 64 20 79 | 6f 75 72 20 61 63 74 75 |ne and y|our actu|
|00000710| 61 6c 0d 6f 75 74 70 75 | 74 2e 20 20 45 2e 67 2e |al.outpu|t. E.g.|
|00000720| 20 69 66 20 79 6f 75 20 | 77 61 6e 74 20 74 6f 20 | if you |want to |
|00000730| 67 65 6e 65 72 61 74 65 | 20 48 54 4d 4c 2c 20 79 |generate| HTML, y|
|00000740| 6f 75 72 20 73 63 72 69 | 70 74 20 63 6f 75 6c 64 |our scri|pt could|
|00000750| 20 73 74 61 72 74 20 61 | 73 0d 66 6f 6c 6c 6f 77 | start a|s.follow|
|00000760| 73 3a 0d 0d 5c 62 65 67 | 69 6e 7b 76 65 72 62 61 |s:..\beg|in{verba|
|00000770| 74 69 6d 7d 0d 23 20 48 | 65 61 64 65 72 20 2d 2d |tim}.# H|eader --|
|00000780| 20 6f 6e 65 20 6f 72 20 | 6d 6f 72 65 20 6c 69 6e | one or |more lin|
|00000790| 65 73 3a 0d 70 72 69 6e | 74 20 22 43 6f 6e 74 65 |es:.prin|t "Conte|
|000007a0| 6e 74 2d 74 79 70 65 3a | 20 74 65 78 74 2f 68 74 |nt-type:| text/ht|
|000007b0| 6d 6c 22 0d 23 20 42 6c | 61 6e 6b 20 6c 69 6e 65 |ml".# Bl|ank line|
|000007c0| 20 73 65 70 61 72 61 74 | 69 6e 67 20 68 65 61 64 | separat|ing head|
|000007d0| 65 72 20 66 72 6f 6d 20 | 62 6f 64 79 3a 0d 70 72 |er from |body:.pr|
|000007e0| 69 6e 74 0d 23 20 42 6f | 64 79 2c 20 69 6e 20 48 |int.# Bo|dy, in H|
|000007f0| 54 4d 4c 20 66 6f 72 6d | 61 74 3a 0d 70 72 69 6e |TML form|at:.prin|
|00000800| 74 20 22 3c 54 49 54 4c | 45 3e 54 68 65 20 41 6d |t "<TITL|E>The Am|
|00000810| 61 7a 69 6e 67 20 53 50 | 41 4d 20 48 6f 6d 65 70 |azing SP|AM Homep|
|00000820| 61 67 65 21 3c 2f 54 49 | 54 4c 45 3e 22 0d 23 20 |age!</TI|TLE>".# |
|00000830| 65 74 63 2e 2e 2e 0d 5c | 65 6e 64 7b 76 65 72 62 |etc....\|end{verb|
|00000840| 61 74 69 6d 7d 0d 0d 54 | 68 65 20 73 65 72 76 65 |atim}..T|he serve|
|00000850| 72 20 77 69 6c 6c 20 61 | 64 64 20 73 6f 6d 65 20 |r will a|dd some |
|00000860| 68 65 61 64 65 72 20 6c | 69 6e 65 73 20 6f 66 20 |header l|ines of |
|00000870| 69 74 73 20 6f 77 6e 2c | 20 62 75 74 20 69 74 20 |its own,| but it |
|00000880| 77 6f 6e 27 74 20 74 6f | 75 63 68 0d 74 68 65 20 |won't to|uch.the |
|00000890| 6f 75 74 70 75 74 20 66 | 6f 6c 6c 6f 77 69 6e 67 |output f|ollowing|
|000008a0| 20 74 68 65 20 68 65 61 | 64 65 72 2e 0d 0d 54 68 | the hea|der...Th|
|000008b0| 65 20 5c 63 6f 64 65 7b | 63 67 69 7d 20 6d 6f 64 |e \code{|cgi} mod|
|000008c0| 75 6c 65 20 64 65 66 69 | 6e 65 73 20 74 68 65 20 |ule defi|nes the |
|000008d0| 66 6f 6c 6c 6f 77 69 6e | 67 20 66 75 6e 63 74 69 |followin|g functi|
|000008e0| 6f 6e 73 3a 0d 0d 5c 62 | 65 67 69 6e 7b 66 75 6e |ons:..\b|egin{fun|
|000008f0| 63 64 65 73 63 7d 7b 70 | 61 72 73 65 7d 7b 7d 0d |cdesc}{p|arse}{}.|
|00000900| 52 65 61 64 20 61 6e 64 | 20 70 61 72 73 65 20 74 |Read and| parse t|
|00000910| 68 65 20 66 6f 72 6d 20 | 73 75 62 6d 69 74 74 65 |he form |submitte|
|00000920| 64 20 74 6f 20 74 68 65 | 20 73 63 72 69 70 74 20 |d to the| script |
|00000930| 61 6e 64 20 72 65 74 75 | 72 6e 20 61 0d 64 69 63 |and retu|rn a.dic|
|00000940| 74 69 6f 6e 61 72 79 20 | 63 6f 6e 74 61 69 6e 69 |tionary |containi|
|00000950| 6e 67 20 74 68 65 20 66 | 6f 72 6d 27 73 20 66 69 |ng the f|orm's fi|
|00000960| 65 6c 64 73 2e 20 20 54 | 68 69 73 20 73 68 6f 75 |elds. T|his shou|
|00000970| 6c 64 20 62 65 20 63 61 | 6c 6c 65 64 20 61 74 0d |ld be ca|lled at.|
|00000980| 6d 6f 73 74 20 6f 6e 63 | 65 20 70 65 72 20 73 63 |most onc|e per sc|
|00000990| 72 69 70 74 20 69 6e 76 | 6f 63 61 74 69 6f 6e 2c |ript inv|ocation,|
|000009a0| 20 61 73 20 69 74 20 6d | 61 79 20 63 6f 6e 73 75 | as it m|ay consu|
|000009b0| 6d 65 20 73 74 61 6e 64 | 61 72 64 20 69 6e 70 75 |me stand|ard inpu|
|000009c0| 74 20 28 69 66 0d 74 68 | 65 20 66 6f 72 6d 20 77 |t (if.th|e form w|
|000009d0| 61 73 20 73 75 62 6d 69 | 74 74 65 64 20 74 68 72 |as submi|tted thr|
|000009e0| 6f 75 67 68 20 61 20 50 | 4f 53 54 20 72 65 71 75 |ough a P|OST requ|
|000009f0| 65 73 74 29 2e 20 20 54 | 68 65 20 6b 65 79 73 20 |est). T|he keys |
|00000a00| 69 6e 20 74 68 65 0d 72 | 65 73 75 6c 74 69 6e 67 |in the.r|esulting|
|00000a10| 20 64 69 63 74 69 6f 6e | 61 72 79 20 61 72 65 20 | diction|ary are |
|00000a20| 74 68 65 20 66 69 65 6c | 64 20 6e 61 6d 65 73 20 |the fiel|d names |
|00000a30| 75 73 65 64 20 69 6e 20 | 74 68 65 20 73 75 62 6d |used in |the subm|
|00000a40| 69 73 73 69 6f 6e 3b 20 | 74 68 65 0d 76 61 6c 75 |ission; |the.valu|
|00000a50| 65 73 20 61 72 65 20 7b | 5c 65 6d 20 6c 69 73 74 |es are {|\em list|
|00000a60| 73 7d 20 6f 66 20 74 68 | 65 20 66 69 65 6c 64 20 |s} of th|e field |
|00000a70| 76 61 6c 75 65 73 20 28 | 73 69 6e 63 65 20 66 69 |values (|since fi|
|00000a80| 65 6c 64 20 6e 61 6d 65 | 20 6d 61 79 20 62 65 0d |eld name| may be.|
|00000a90| 75 73 65 64 20 6d 75 6c | 74 69 70 6c 65 20 74 69 |used mul|tiple ti|
|00000aa0| 6d 65 73 20 69 6e 20 61 | 20 73 69 6e 67 6c 65 20 |mes in a| single |
|00000ab0| 66 6f 72 6d 29 2e 20 20 | 5c 73 61 6d 70 7b 5c 25 |form). |\samp{\%|
|00000ac0| 7d 20 65 73 63 61 70 65 | 73 20 69 6e 20 74 68 65 |} escape|s in the|
|00000ad0| 0d 76 61 6c 75 65 73 20 | 61 72 65 20 74 72 61 6e |.values |are tran|
|00000ae0| 73 6c 61 74 65 64 20 74 | 6f 20 74 68 65 69 72 20 |slated t|o their |
|00000af0| 73 69 6e 67 6c 65 2d 63 | 68 61 72 61 63 74 65 72 |single-c|haracter|
|00000b00| 20 65 71 75 69 76 61 6c | 65 6e 74 20 75 73 69 6e | equival|ent usin|
|00000b10| 67 0d 5c 63 6f 64 65 7b | 75 72 6c 6c 69 62 2e 75 |g.\code{|urllib.u|
|00000b20| 6e 71 75 6f 74 65 28 29 | 7d 2e 20 20 41 73 20 61 |nquote()|}. As a|
|00000b30| 20 73 69 64 65 20 65 66 | 66 65 63 74 2c 20 74 68 | side ef|fect, th|
|00000b40| 69 73 20 66 75 6e 63 74 | 69 6f 6e 20 73 65 74 73 |is funct|ion sets|
|00000b50| 0d 5c 63 6f 64 65 7b 65 | 6e 76 69 72 6f 6e 5b 27 |.\code{e|nviron['|
|00000b60| 51 55 45 52 59 5f 53 54 | 52 49 4e 47 27 5d 7d 20 |QUERY_ST|RING']} |
|00000b70| 74 6f 20 74 68 65 20 72 | 61 77 20 71 75 65 72 79 |to the r|aw query|
|00000b80| 20 73 74 72 69 6e 67 2c | 20 69 66 20 69 74 20 69 | string,| if it i|
|00000b90| 73 6e 27 74 0d 61 6c 72 | 65 61 64 79 20 73 65 74 |sn't.alr|eady set|
|00000ba0| 2e 0d 5c 65 6e 64 7b 66 | 75 6e 63 64 65 73 63 7d |..\end{f|uncdesc}|
|00000bb0| 0d 0d 5c 62 65 67 69 6e | 7b 66 75 6e 63 64 65 73 |..\begin|{funcdes|
|00000bc0| 63 7d 7b 70 72 69 6e 74 | 5f 65 6e 76 69 72 6f 6e |c}{print|_environ|
|00000bd0| 5f 75 73 61 67 65 7d 7b | 7d 0d 50 72 69 6e 74 20 |_usage}{|}.Print |
|00000be0| 61 20 70 69 65 63 65 20 | 6f 66 20 48 54 4d 4c 20 |a piece |of HTML |
|00000bf0| 6c 69 73 74 69 6e 67 20 | 74 68 65 20 65 6e 76 69 |listing |the envi|
|00000c00| 72 6f 6e 6d 65 6e 74 20 | 76 61 72 69 61 62 6c 65 |ronment |variable|
|00000c10| 73 20 74 68 61 74 20 6d | 61 79 20 62 65 0d 73 65 |s that m|ay be.se|
|00000c20| 74 20 62 79 20 74 68 65 | 20 43 47 49 20 70 72 6f |t by the| CGI pro|
|00000c30| 74 6f 63 6f 6c 2e 0d 54 | 68 69 73 20 69 73 20 6d |tocol..T|his is m|
|00000c40| 61 69 6e 6c 79 20 75 73 | 65 66 75 6c 20 77 68 65 |ainly us|eful whe|
|00000c50| 6e 20 6c 65 61 72 6e 69 | 6e 67 20 61 62 6f 75 74 |n learni|ng about|
|00000c60| 20 77 72 69 74 69 6e 67 | 20 43 47 49 20 73 63 72 | writing| CGI scr|
|00000c70| 69 70 74 73 2e 0d 5c 65 | 6e 64 7b 66 75 6e 63 64 |ipts..\e|nd{funcd|
|00000c80| 65 73 63 7d 0d 0d 5c 62 | 65 67 69 6e 7b 66 75 6e |esc}..\b|egin{fun|
|00000c90| 63 64 65 73 63 7d 7b 70 | 72 69 6e 74 5f 65 6e 76 |cdesc}{p|rint_env|
|00000ca0| 69 72 6f 6e 7d 7b 7d 0d | 50 72 69 6e 74 20 61 20 |iron}{}.|Print a |
|00000cb0| 70 69 65 63 65 20 6f 66 | 20 48 54 4d 4c 20 74 65 |piece of| HTML te|
|00000cc0| 78 74 20 73 68 6f 77 69 | 6e 67 20 74 68 65 20 65 |xt showi|ng the e|
|00000cd0| 6e 74 69 72 65 20 63 6f | 6e 74 65 6e 74 73 20 6f |ntire co|ntents o|
|00000ce0| 66 20 74 68 65 20 73 68 | 65 6c 6c 0d 65 6e 76 69 |f the sh|ell.envi|
|00000cf0| 72 6f 6e 6d 65 6e 74 2e | 20 20 54 68 69 73 20 69 |ronment.| This i|
|00000d00| 73 20 6d 61 69 6e 6c 79 | 20 75 73 65 66 75 6c 20 |s mainly| useful |
|00000d10| 77 68 65 6e 20 64 65 62 | 75 67 67 69 6e 67 20 61 |when deb|ugging a|
|00000d20| 20 43 47 49 20 73 63 72 | 69 70 74 2e 0d 5c 65 6e | CGI scr|ipt..\en|
|00000d30| 64 7b 66 75 6e 63 64 65 | 73 63 7d 0d 0d 5c 62 65 |d{funcde|sc}..\be|
|00000d40| 67 69 6e 7b 66 75 6e 63 | 64 65 73 63 7d 7b 70 72 |gin{func|desc}{pr|
|00000d50| 69 6e 74 5f 66 6f 72 6d | 7d 7b 66 6f 72 6d 7d 0d |int_form|}{form}.|
|00000d60| 50 72 69 6e 74 20 61 20 | 70 69 65 63 65 20 6f 66 |Print a |piece of|
|00000d70| 20 48 54 4d 4c 20 74 65 | 78 74 20 73 68 6f 77 69 | HTML te|xt showi|
|00000d80| 6e 67 20 74 68 65 20 63 | 6f 6e 74 65 6e 74 73 20 |ng the c|ontents |
|00000d90| 6f 66 20 74 68 65 20 5c | 76 61 72 7b 66 6f 72 6d |of the \|var{form|
|00000da0| 7d 20 28 61 0d 64 69 63 | 74 69 6f 6e 61 72 79 2c |} (a.dic|tionary,|
|00000db0| 20 61 6e 20 69 6e 73 74 | 61 6e 63 65 20 6f 66 20 | an inst|ance of |
|00000dc0| 74 68 65 20 5c 63 6f 64 | 65 7b 46 6f 72 6d 43 6f |the \cod|e{FormCo|
|00000dd0| 6e 74 65 6e 74 44 69 63 | 74 7d 20 63 6c 61 73 73 |ntentDic|t} class|
|00000de0| 20 64 65 66 69 6e 65 64 | 0d 62 65 6c 6f 77 2c 20 | defined|.below, |
|00000df0| 6f 72 20 61 20 73 75 62 | 63 6c 61 73 73 20 74 68 |or a sub|class th|
|00000e00| 65 72 65 6f 66 29 2e 0d | 54 68 69 73 20 69 73 20 |ereof)..|This is |
|00000e10| 6d 61 69 6e 6c 79 20 75 | 73 65 66 75 6c 20 77 68 |mainly u|seful wh|
|00000e20| 65 6e 20 64 65 62 75 67 | 67 69 6e 67 20 61 20 43 |en debug|ging a C|
|00000e30| 47 49 20 73 63 72 69 70 | 74 2e 0d 5c 65 6e 64 7b |GI scrip|t..\end{|
|00000e40| 66 75 6e 63 64 65 73 63 | 7d 0d 0d 5c 62 65 67 69 |funcdesc|}..\begi|
|00000e50| 6e 7b 66 75 6e 63 64 65 | 73 63 7d 7b 65 73 63 61 |n{funcde|sc}{esca|
|00000e60| 70 65 7d 7b 73 74 72 69 | 6e 67 7d 0d 43 6f 6e 76 |pe}{stri|ng}.Conv|
|00000e70| 65 72 74 20 73 70 65 63 | 69 61 6c 20 63 68 61 72 |ert spec|ial char|
|00000e80| 61 63 74 65 72 73 20 69 | 6e 20 5c 76 61 72 7b 73 |acters i|n \var{s|
|00000e90| 74 72 69 6e 67 7d 20 74 | 6f 20 48 54 4d 4c 20 65 |tring} t|o HTML e|
|00000ea0| 73 63 61 70 65 73 2e 20 | 20 49 6e 0d 70 61 72 74 |scapes. | In.part|
|00000eb0| 69 63 75 6c 61 72 2c 20 | 60 60 5c 63 6f 64 65 7b |icular, |``\code{|
|00000ec0| 5c 26 7d 27 27 20 69 73 | 20 72 65 70 6c 61 63 65 |\&}'' is| replace|
|00000ed0| 64 20 77 69 74 68 20 60 | 60 5c 63 6f 64 65 7b 5c |d with `|`\code{\|
|00000ee0| 26 61 6d 70 3b 7d 27 27 | 2c 0d 60 60 5c 63 6f 64 |&}''|,.``\cod|
|00000ef0| 65 7b 3c 7d 27 27 20 69 | 73 20 72 65 70 6c 61 63 |e{<}'' i|s replac|
|00000f00| 65 64 20 77 69 74 68 20 | 60 60 5c 63 6f 64 65 7b |ed with |``\code{|
|00000f10| 5c 26 6c 74 3b 7d 27 27 | 2c 20 61 6e 64 20 60 60 |\<}''|, and ``|
|00000f20| 5c 63 6f 64 65 7b 3e 7d | 27 27 20 69 73 0d 72 65 |\code{>}|'' is.re|
|00000f30| 70 6c 61 63 65 64 20 77 | 69 74 68 20 60 60 5c 63 |placed w|ith ``\c|
|00000f40| 6f 64 65 7b 5c 26 67 74 | 3b 7d 27 27 2e 20 20 54 |ode{\>|;}''. T|
|00000f50| 68 69 73 20 69 73 20 75 | 73 65 66 75 6c 20 77 68 |his is u|seful wh|
|00000f60| 65 6e 20 70 72 69 6e 74 | 69 6e 67 20 28 61 6c 6d |en print|ing (alm|
|00000f70| 6f 73 74 29 0d 61 72 62 | 69 74 72 61 72 79 20 74 |ost).arb|itrary t|
|00000f80| 65 78 74 20 69 6e 20 61 | 6e 20 48 54 4d 4c 20 63 |ext in a|n HTML c|
|00000f90| 6f 6e 74 65 78 74 2e 20 | 20 4e 6f 74 65 20 74 68 |ontext. | Note th|
|00000fa0| 61 74 20 66 6f 72 20 69 | 6e 63 6c 75 73 69 6f 6e |at for i|nclusion|
|00000fb0| 20 69 6e 20 71 75 6f 74 | 65 64 0d 74 61 67 20 61 | in quot|ed.tag a|
|00000fc0| 74 74 72 69 62 75 74 65 | 73 20 28 65 2e 67 2e 20 |ttribute|s (e.g. |
|00000fd0| 5c 63 6f 64 65 7b 3c 41 | 20 48 52 45 46 3d 22 2e |\code{<A| HREF=".|
|00000fe0| 2e 2e 22 3e 7d 29 2c 20 | 73 6f 6d 65 20 61 64 64 |..">}), |some add|
|00000ff0| 69 74 69 6f 6e 61 6c 0d | 63 68 61 72 61 63 74 65 |itional.|characte|
|00001000| 72 73 20 77 6f 75 6c 64 | 20 68 61 76 65 20 74 6f |rs would| have to|
|00001010| 20 62 65 20 63 6f 6e 76 | 65 72 74 65 64 20 2d 2d | be conv|erted --|
|00001020| 2d 20 69 6e 20 70 61 72 | 74 69 63 75 6c 61 72 20 |- in par|ticular |
|00001030| 74 68 65 20 73 74 72 69 | 6e 67 0d 71 75 6f 74 65 |the stri|ng.quote|
|00001040| 2e 20 20 54 68 65 72 65 | 20 69 73 20 63 75 72 72 |. There| is curr|
|00001050| 65 6e 74 6c 79 20 6e 6f | 20 66 75 6e 63 74 69 6f |ently no| functio|
|00001060| 6e 20 74 68 61 74 20 64 | 6f 65 73 20 74 68 69 73 |n that d|oes this|
|00001070| 2e 0d 5c 65 6e 64 7b 66 | 75 6e 63 64 65 73 63 7d |..\end{f|uncdesc}|
|00001080| 0d 0d 54 68 65 20 6d 6f | 64 75 6c 65 20 64 65 66 |..The mo|dule def|
|00001090| 69 6e 65 73 20 74 68 65 | 20 66 6f 6c 6c 6f 77 69 |ines the| followi|
|000010a0| 6e 67 20 63 6c 61 73 73 | 65 73 2e 20 20 53 69 6e |ng class|es. Sin|
|000010b0| 63 65 20 74 68 65 20 62 | 61 73 65 20 63 6c 61 73 |ce the b|ase clas|
|000010c0| 73 0d 69 6e 69 74 69 61 | 6c 69 7a 65 73 20 69 74 |s.initia|lizes it|
|000010d0| 73 65 6c 66 20 62 79 20 | 63 61 6c 6c 69 6e 67 20 |self by |calling |
|000010e0| 5c 63 6f 64 65 7b 70 61 | 72 73 65 28 29 7d 2c 20 |\code{pa|rse()}, |
|000010f0| 61 74 20 6d 6f 73 74 20 | 6f 6e 65 20 69 6e 73 74 |at most |one inst|
|00001100| 61 6e 63 65 20 6f 66 0d | 61 74 20 6d 6f 73 74 20 |ance of.|at most |
|00001110| 6f 6e 65 20 6f 66 20 74 | 68 65 73 65 20 63 6c 61 |one of t|hese cla|
|00001120| 73 73 65 73 20 73 68 6f | 75 6c 64 20 62 65 20 63 |sses sho|uld be c|
|00001130| 72 65 61 74 65 64 20 70 | 65 72 20 73 63 72 69 70 |reated p|er scrip|
|00001140| 74 20 69 6e 76 6f 63 61 | 74 69 6f 6e 3a 0d 0d 5c |t invoca|tion:..\|
|00001150| 62 65 67 69 6e 7b 66 75 | 6e 63 64 65 73 63 7d 7b |begin{fu|ncdesc}{|
|00001160| 46 6f 72 6d 43 6f 6e 74 | 65 6e 74 44 69 63 74 7d |FormCont|entDict}|
|00001170| 7b 7d 0d 54 68 69 73 20 | 63 6c 61 73 73 20 62 65 |{}.This |class be|
|00001180| 68 61 76 65 73 20 6c 69 | 6b 65 20 61 20 28 72 65 |haves li|ke a (re|
|00001190| 61 64 2d 6f 6e 6c 79 29 | 20 64 69 63 74 69 6f 6e |ad-only)| diction|
|000011a0| 61 72 79 20 61 6e 64 20 | 68 61 73 20 74 68 65 20 |ary and |has the |
|000011b0| 73 61 6d 65 20 6b 65 79 | 73 0d 61 6e 64 20 76 61 |same key|s.and va|
|000011c0| 6c 75 65 73 20 61 73 20 | 74 68 65 20 64 69 63 74 |lues as |the dict|
|000011d0| 69 6f 6e 61 72 79 20 72 | 65 74 75 72 6e 65 64 20 |ionary r|eturned |
|000011e0| 62 79 20 5c 63 6f 64 65 | 7b 70 61 72 73 65 28 29 |by \code|{parse()|
|000011f0| 7d 20 28 69 2e 65 2e 20 | 65 61 63 68 0d 66 69 65 |} (i.e. |each.fie|
|00001200| 6c 64 20 6e 61 6d 65 20 | 6d 61 70 73 20 74 6f 20 |ld name |maps to |
|00001210| 61 20 6c 69 73 74 20 6f | 66 20 76 61 6c 75 65 73 |a list o|f values|
|00001220| 29 2e 20 20 41 64 64 69 | 74 69 6f 6e 61 6c 6c 79 |). Addi|tionally|
|00001230| 2c 20 69 74 20 69 6e 69 | 74 69 61 6c 69 7a 65 73 |, it ini|tializes|
|00001240| 0d 69 74 73 20 64 61 74 | 61 20 6d 65 6d 62 65 72 |.its dat|a member|
|00001250| 20 5c 63 6f 64 65 7b 71 | 75 65 72 79 5f 73 74 72 | \code{q|uery_str|
|00001260| 69 6e 67 7d 20 74 6f 20 | 74 68 65 20 72 61 77 20 |ing} to |the raw |
|00001270| 71 75 65 72 79 20 73 65 | 6e 74 20 66 72 6f 6d 20 |query se|nt from |
|00001280| 74 68 65 0d 73 65 72 76 | 65 72 2e 0d 5c 65 6e 64 |the.serv|er..\end|
|00001290| 7b 66 75 6e 63 64 65 73 | 63 7d 0d 0d 5c 62 65 67 |{funcdes|c}..\beg|
|000012a0| 69 6e 7b 66 75 6e 63 64 | 65 73 63 7d 7b 53 76 46 |in{funcd|esc}{SvF|
|000012b0| 6f 72 6d 43 6f 6e 74 65 | 6e 74 44 69 63 74 7d 7b |ormConte|ntDict}{|
|000012c0| 7d 0d 54 68 69 73 20 63 | 6c 61 73 73 2c 20 64 65 |}.This c|lass, de|
|000012d0| 72 69 76 65 64 20 66 72 | 6f 6d 20 5c 63 6f 64 65 |rived fr|om \code|
|000012e0| 7b 46 6f 72 6d 43 6f 6e | 74 65 6e 74 44 69 63 74 |{FormCon|tentDict|
|000012f0| 7d 2c 20 69 73 20 61 20 | 6c 69 74 74 6c 65 20 6d |}, is a |little m|
|00001300| 6f 72 65 0d 75 73 65 72 | 2d 66 72 69 65 6e 64 6c |ore.user|-friendl|
|00001310| 79 20 77 68 65 6e 20 79 | 6f 75 20 61 72 65 20 65 |y when y|ou are e|
|00001320| 78 70 65 63 74 69 6e 67 | 20 74 68 61 74 20 65 61 |xpecting| that ea|
|00001330| 63 68 20 66 69 65 6c 64 | 20 6e 61 6d 65 20 69 73 |ch field| name is|
|00001340| 20 6f 6e 6c 79 20 75 73 | 65 64 0d 6f 6e 63 65 20 | only us|ed.once |
|00001350| 69 6e 20 74 68 65 20 66 | 6f 72 6d 2e 20 20 57 68 |in the f|orm. Wh|
|00001360| 65 6e 20 79 6f 75 20 61 | 63 63 65 73 73 20 66 6f |en you a|ccess fo|
|00001370| 72 20 61 20 70 61 72 74 | 69 63 75 6c 61 72 20 66 |r a part|icular f|
|00001380| 69 65 6c 64 20 28 75 73 | 69 6e 67 0d 5c 63 6f 64 |ield (us|ing.\cod|
|00001390| 65 7b 66 6f 72 6d 5b 66 | 69 65 6c 64 6e 61 6d 65 |e{form[f|ieldname|
|000013a0| 5d 7d 29 2c 20 69 74 20 | 77 69 6c 6c 20 72 65 74 |]}), it |will ret|
|000013b0| 75 72 6e 20 74 68 65 20 | 73 74 72 69 6e 67 20 76 |urn the |string v|
|000013c0| 61 6c 75 65 20 6f 66 20 | 74 68 61 74 20 69 74 65 |alue of |that ite|
|000013d0| 6d 0d 69 66 20 69 74 20 | 69 73 20 75 6e 69 71 75 |m.if it |is uniqu|
|000013e0| 65 2c 20 6f 72 20 72 61 | 69 73 65 20 5c 63 6f 64 |e, or ra|ise \cod|
|000013f0| 65 7b 49 6e 64 65 78 45 | 72 72 6f 72 7d 20 69 66 |e{IndexE|rror} if|
|00001400| 20 74 68 65 20 66 69 65 | 6c 64 20 77 61 73 20 73 | the fie|ld was s|
|00001410| 70 65 63 69 66 69 65 64 | 0d 6d 6f 72 65 20 74 68 |pecified|.more th|
|00001420| 61 6e 20 6f 6e 63 65 20 | 69 6e 20 74 68 65 20 66 |an once |in the f|
|00001430| 6f 72 6d 2e 20 20 28 49 | 66 20 74 68 65 20 66 69 |orm. (I|f the fi|
|00001440| 65 6c 64 20 77 61 73 6e | 27 74 20 73 70 65 63 69 |eld wasn|'t speci|
|00001450| 66 69 65 64 20 61 74 20 | 61 6c 6c 2c 0d 5c 63 6f |fied at |all,.\co|
|00001460| 64 65 7b 4b 65 79 45 72 | 72 6f 72 7d 20 69 73 20 |de{KeyEr|ror} is |
|00001470| 72 61 69 73 65 64 2e 29 | 20 20 54 6f 20 61 63 63 |raised.)| To acc|
|00001480| 65 73 73 20 66 69 65 6c | 64 73 20 74 68 61 74 20 |ess fiel|ds that |
|00001490| 61 72 65 20 73 70 65 63 | 69 66 69 65 64 0d 6d 75 |are spec|ified.mu|
|000014a0| 6c 74 69 70 6c 65 20 74 | 69 6d 65 73 2c 20 75 73 |ltiple t|imes, us|
|000014b0| 65 20 5c 63 6f 64 65 7b | 66 6f 72 6d 2e 67 65 74 |e \code{|form.get|
|000014c0| 6c 69 73 74 28 66 69 65 | 6c 64 6e 61 6d 65 29 7d |list(fie|ldname)}|
|000014d0| 2e 20 20 54 68 65 0d 5c | 63 6f 64 65 7b 76 61 6c |. The.\|code{val|
|000014e0| 75 65 73 28 29 7d 20 61 | 6e 64 20 5c 63 6f 64 65 |ues()} a|nd \code|
|000014f0| 7b 69 74 65 6d 73 28 29 | 7d 20 6d 65 74 68 6f 64 |{items()|} method|
|00001500| 73 20 72 65 74 75 72 6e | 20 6d 69 78 65 64 20 6c |s return| mixed l|
|00001510| 69 73 74 73 20 2d 2d 2d | 0d 63 6f 6e 74 61 69 6e |ists ---|.contain|
|00001520| 69 6e 67 20 73 74 72 69 | 6e 67 73 20 66 6f 72 20 |ing stri|ngs for |
|00001530| 73 69 6e 67 6c 79 2d 64 | 65 66 69 6e 65 64 20 66 |singly-d|efined f|
|00001540| 69 65 6c 64 73 2c 20 61 | 6e 64 20 6c 69 73 74 73 |ields, a|nd lists|
|00001550| 20 6f 66 20 73 74 72 69 | 6e 67 73 20 66 6f 72 0d | of stri|ngs for.|
|00001560| 6d 75 6c 74 69 70 6c 79 | 2d 64 65 66 69 6e 65 64 |multiply|-defined|
|00001570| 20 66 69 65 6c 64 73 2e | 0d 5c 65 6e 64 7b 66 75 | fields.|.\end{fu|
|00001580| 6e 63 64 65 73 63 7d 0d | 0d 28 49 74 20 63 75 72 |ncdesc}.|.(It cur|
|00001590| 72 65 6e 74 6c 79 20 64 | 65 66 69 6e 65 73 20 73 |rently d|efines s|
|000015a0| 6f 6d 65 20 6d 6f 72 65 | 20 63 6c 61 73 73 65 73 |ome more| classes|
|000015b0| 2c 20 62 75 74 20 74 68 | 65 73 65 20 61 72 65 20 |, but th|ese are |
|000015c0| 65 78 70 65 72 69 6d 65 | 6e 74 61 6c 0d 61 6e 64 |experime|ntal.and|
|000015d0| 2f 6f 72 20 6f 62 73 6f | 6c 65 73 63 65 6e 74 2c |/or obso|lescent,|
|000015e0| 20 61 6e 64 20 61 72 65 | 20 74 68 75 73 20 6e 6f | and are| thus no|
|000015f0| 74 20 64 6f 63 75 6d 65 | 6e 74 65 64 20 2d 2d 2d |t docume|nted ---|
|00001600| 20 73 65 65 20 74 68 65 | 20 73 6f 75 72 63 65 20 | see the| source |
|00001610| 66 6f 72 0d 6d 6f 72 65 | 20 69 6e 66 6f 72 6d 61 |for.more| informa|
|00001620| 74 69 6f 6e 73 2e 29 0d | 0d 54 68 65 20 6d 6f 64 |tions.).|.The mod|
|00001630| 75 6c 65 20 64 65 66 69 | 6e 65 73 20 74 68 65 20 |ule defi|nes the |
|00001640| 66 6f 6c 6c 6f 77 69 6e | 67 20 76 61 72 69 61 62 |followin|g variab|
|00001650| 6c 65 3a 0d 0d 5c 62 65 | 67 69 6e 7b 64 61 74 61 |le:..\be|gin{data|
|00001660| 64 65 73 63 7d 7b 65 6e | 76 69 72 6f 6e 7d 0d 54 |desc}{en|viron}.T|
|00001670| 68 65 20 73 68 65 6c 6c | 20 65 6e 76 69 72 6f 6e |he shell| environ|
|00001680| 6d 65 6e 74 2c 20 65 78 | 61 63 74 6c 79 20 61 73 |ment, ex|actly as|
|00001690| 20 72 65 63 65 69 76 65 | 64 20 66 72 6f 6d 20 74 | receive|d from t|
|000016a0| 68 65 20 68 74 74 70 20 | 73 65 72 76 65 72 2e 20 |he http |server. |
|000016b0| 20 53 65 65 0d 74 68 65 | 20 43 47 49 20 64 6f 63 | See.the| CGI doc|
|000016c0| 75 6d 65 6e 74 61 74 69 | 6f 6e 20 66 6f 72 20 61 |umentati|on for a|
|000016d0| 20 64 65 73 63 72 69 70 | 74 69 6f 6e 20 6f 66 20 | descrip|tion of |
|000016e0| 74 68 65 20 76 61 72 69 | 6f 75 73 20 66 69 65 6c |the vari|ous fiel|
|000016f0| 64 73 2e 0d 5c 65 6e 64 | 7b 64 61 74 61 64 65 73 |ds..\end|{datades|
|00001700| 63 7d 0d 0d 5c 73 75 62 | 73 65 63 74 69 6f 6e 7b |c}..\sub|section{|
|00001710| 45 78 61 6d 70 6c 65 7d | 0d 5c 6e 6f 64 65 6e 61 |Example}|.\nodena|
|00001720| 6d 65 7b 43 47 49 20 45 | 78 61 6d 70 6c 65 7d 0d |me{CGI E|xample}.|
|00001730| 0d 54 68 69 73 20 65 78 | 61 6d 70 6c 65 20 61 73 |.This ex|ample as|
|00001740| 73 75 6d 65 73 20 74 68 | 61 74 20 79 6f 75 20 68 |sumes th|at you h|
|00001750| 61 76 65 20 61 20 57 57 | 57 20 73 65 72 76 65 72 |ave a WW|W server|
|00001760| 20 75 70 20 61 6e 64 20 | 72 75 6e 6e 69 6e 67 2c | up and |running,|
|00001770| 0d 65 2e 67 2e 5c 20 4e | 43 53 41 27 73 20 5c 63 |.e.g.\ N|CSA's \c|
|00001780| 6f 64 65 7b 68 74 74 70 | 64 7d 2e 0d 0d 50 6c 61 |ode{http|d}...Pla|
|00001790| 63 65 20 74 68 65 20 66 | 6f 6c 6c 6f 77 69 6e 67 |ce the f|ollowing|
|000017a0| 20 66 69 6c 65 20 69 6e | 20 61 20 63 6f 6e 76 65 | file in| a conve|
|000017b0| 6e 69 65 6e 74 20 73 70 | 6f 74 20 69 6e 20 74 68 |nient sp|ot in th|
|000017c0| 65 20 57 57 57 20 73 65 | 72 76 65 72 27 73 0d 64 |e WWW se|rver's.d|
|000017d0| 69 72 65 63 74 6f 72 79 | 20 74 72 65 65 2e 20 20 |irectory| tree. |
|000017e0| 45 2e 67 2e 2c 20 69 66 | 20 79 6f 75 20 70 6c 61 |E.g., if| you pla|
|000017f0| 63 65 20 69 74 20 69 6e | 20 74 68 65 20 73 75 62 |ce it in| the sub|
|00001800| 64 69 72 65 63 74 6f 72 | 79 20 5c 66 69 6c 65 7b |director|y \file{|
|00001810| 74 65 73 74 7d 0d 6f 66 | 20 74 68 65 20 72 6f 6f |test}.of| the roo|
|00001820| 74 20 64 69 72 65 63 74 | 6f 72 79 20 61 6e 64 20 |t direct|ory and |
|00001830| 63 61 6c 6c 20 69 74 20 | 5c 66 69 6c 65 7b 74 65 |call it |\file{te|
|00001840| 73 74 2e 68 74 6d 6c 7d | 2c 20 69 74 73 20 55 52 |st.html}|, its UR|
|00001850| 4c 20 77 69 6c 6c 20 62 | 65 0d 5c 66 69 6c 65 7b |L will b|e.\file{|
|00001860| 68 74 74 70 3a 2f 2f 5c | 76 61 72 7b 79 6f 75 72 |http://\|var{your|
|00001870| 73 65 72 76 65 72 6e 61 | 6d 65 7d 2f 74 65 73 74 |serverna|me}/test|
|00001880| 2f 74 65 73 74 2e 68 74 | 6d 6c 7d 2e 0d 0d 5c 62 |/test.ht|ml}...\b|
|00001890| 65 67 69 6e 7b 76 65 72 | 62 61 74 69 6d 7d 0d 3c |egin{ver|batim}.<|
|000018a0| 54 49 54 4c 45 3e 54 65 | 73 74 20 46 6f 72 6d 20 |TITLE>Te|st Form |
|000018b0| 49 6e 70 75 74 3c 2f 54 | 49 54 4c 45 3e 0d 3c 48 |Input</T|ITLE>.<H|
|000018c0| 31 3e 54 65 73 74 20 46 | 6f 72 6d 20 49 6e 70 75 |1>Test F|orm Inpu|
|000018d0| 74 3c 2f 48 31 3e 0d 3c | 46 4f 52 4d 20 4d 45 54 |t</H1>.<|FORM MET|
|000018e0| 48 4f 44 3d 22 50 4f 53 | 54 22 20 41 43 54 49 4f |HOD="POS|T" ACTIO|
|000018f0| 4e 3d 22 2f 63 67 69 2d | 62 69 6e 2f 74 65 73 74 |N="/cgi-|bin/test|
|00001900| 2e 70 79 22 3e 0d 3c 49 | 4e 50 55 54 20 4e 41 4d |.py">.<I|NPUT NAM|
|00001910| 45 3d 4e 61 6d 65 3e 20 | 28 4e 61 6d 65 29 3c 62 |E=Name> |(Name)<b|
|00001920| 72 3e 0d 3c 49 4e 50 55 | 54 20 4e 41 4d 45 3d 41 |r>.<INPU|T NAME=A|
|00001930| 64 64 72 65 73 73 3e 20 | 28 41 64 64 72 65 73 73 |ddress> |(Address|
|00001940| 29 3c 62 72 3e 0d 3c 49 | 4e 50 55 54 20 54 59 50 |)<br>.<I|NPUT TYP|
|00001950| 45 3d 53 55 42 4d 49 54 | 3e 0d 3c 2f 46 4f 52 4d |E=SUBMIT|>.</FORM|
|00001960| 3e 0d 5c 65 6e 64 7b 76 | 65 72 62 61 74 69 6d 7d |>.\end{v|erbatim}|
|00001970| 0d 0d 53 65 6c 65 63 74 | 69 6e 67 20 74 68 69 73 |..Select|ing this|
|00001980| 20 66 69 6c 65 27 73 20 | 55 52 4c 20 66 72 6f 6d | file's |URL from|
|00001990| 20 61 20 66 6f 72 6d 73 | 2d 63 61 70 61 62 6c 65 | a forms|-capable|
|000019a0| 20 62 72 6f 77 73 65 72 | 20 73 75 63 68 20 61 73 | browser| such as|
|000019b0| 20 4d 6f 73 61 69 63 0d | 6f 72 20 4e 65 74 73 63 | Mosaic.|or Netsc|
|000019c0| 61 70 65 20 77 69 6c 6c | 20 62 72 69 6e 67 20 75 |ape will| bring u|
|000019d0| 70 20 61 20 73 69 6d 70 | 6c 65 20 66 6f 72 6d 20 |p a simp|le form |
|000019e0| 77 69 74 68 20 74 77 6f | 20 74 65 78 74 20 69 6e |with two| text in|
|000019f0| 70 75 74 20 66 69 65 6c | 64 73 20 61 6e 64 0d 61 |put fiel|ds and.a|
|00001a00| 20 60 60 73 75 62 6d 69 | 74 27 27 20 62 75 74 74 | ``submi|t'' butt|
|00001a10| 6f 6e 2e 0d 0d 42 75 74 | 20 77 61 69 74 2e 20 20 |on...But| wait. |
|00001a20| 42 65 66 6f 72 65 20 70 | 72 65 73 73 69 6e 67 20 |Before p|ressing |
|00001a30| 60 60 73 75 62 6d 69 74 | 27 27 2c 20 61 20 73 63 |``submit|'', a sc|
|00001a40| 72 69 70 74 20 74 68 61 | 74 20 72 65 73 70 6f 6e |ript tha|t respon|
|00001a50| 64 73 20 74 6f 20 74 68 | 65 0d 66 6f 72 6d 20 6d |ds to th|e.form m|
|00001a60| 75 73 74 20 61 6c 73 6f | 20 62 65 20 69 6e 73 74 |ust also| be inst|
|00001a70| 61 6c 6c 65 64 2e 20 20 | 54 68 65 20 74 65 73 74 |alled. |The test|
|00001a80| 20 66 69 6c 65 20 61 73 | 20 73 68 6f 77 6e 20 61 | file as| shown a|
|00001a90| 73 73 75 6d 65 73 20 74 | 68 61 74 20 74 68 65 0d |ssumes t|hat the.|
|00001aa0| 73 63 72 69 70 74 20 69 | 73 20 63 61 6c 6c 65 64 |script i|s called|
|00001ab0| 20 5c 66 69 6c 65 7b 74 | 65 73 74 2e 70 79 7d 20 | \file{t|est.py} |
|00001ac0| 61 6e 64 20 6c 69 76 65 | 73 20 69 6e 20 74 68 65 |and live|s in the|
|00001ad0| 20 73 65 72 76 65 72 27 | 73 0d 5c 63 6f 64 65 7b | server'|s.\code{|
|00001ae0| 63 67 69 2d 62 69 6e 7d | 20 64 69 72 65 63 74 6f |cgi-bin}| directo|
|00001af0| 72 79 2e 20 20 48 65 72 | 65 27 73 20 74 68 65 20 |ry. Her|e's the |
|00001b00| 74 65 73 74 20 73 63 72 | 69 70 74 3a 0d 0d 5c 62 |test scr|ipt:..\b|
|00001b10| 65 67 69 6e 7b 76 65 72 | 62 61 74 69 6d 7d 0d 23 |egin{ver|batim}.#|
|00001b20| 21 2f 75 73 72 2f 6c 6f | 63 61 6c 2f 62 69 6e 2f |!/usr/lo|cal/bin/|
|00001b30| 70 79 74 68 6f 6e 0d 0d | 69 6d 70 6f 72 74 20 63 |python..|import c|
|00001b40| 67 69 0d 0d 70 72 69 6e | 74 20 22 43 6f 6e 74 65 |gi..prin|t "Conte|
|00001b50| 6e 74 2d 74 79 70 65 3a | 20 74 65 78 74 2f 68 74 |nt-type:| text/ht|
|00001b60| 6d 6c 22 0d 70 72 69 6e | 74 20 20 20 20 20 20 20 |ml".prin|t |
|00001b70| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001b80| 20 20 20 20 20 20 20 20 | 20 20 20 20 23 20 45 6e | | # En|
|00001b90| 64 20 6f 66 20 68 65 61 | 64 65 72 73 21 0d 70 72 |d of hea|ders!.pr|
|00001ba0| 69 6e 74 20 22 3c 54 49 | 54 4c 45 3e 54 65 73 74 |int "<TI|TLE>Test|
|00001bb0| 20 46 6f 72 6d 20 4f 75 | 74 70 75 74 3c 2f 54 49 | Form Ou|tput</TI|
|00001bc0| 54 4c 45 3e 22 0d 70 72 | 69 6e 74 20 22 3c 48 31 |TLE>".pr|int "<H1|
|00001bd0| 3e 54 65 73 74 20 46 6f | 72 6d 20 4f 75 74 70 75 |>Test Fo|rm Outpu|
|00001be0| 74 3c 2f 48 31 3e 22 0d | 0d 66 6f 72 6d 20 3d 20 |t</H1>".|.form = |
|00001bf0| 63 67 69 2e 53 76 46 6f | 72 6d 43 6f 6e 74 65 6e |cgi.SvFo|rmConten|
|00001c00| 74 44 69 63 74 28 29 20 | 20 20 20 20 20 20 20 20 |tDict() | |
|00001c10| 20 23 20 4c 6f 61 64 20 | 74 68 65 20 66 6f 72 6d | # Load |the form|
|00001c20| 0d 0d 6e 61 6d 65 20 3d | 20 61 64 64 72 20 3d 20 |..name =| addr = |
|00001c30| 4e 6f 6e 65 20 20 20 20 | 20 20 20 20 20 20 20 20 |None | |
|00001c40| 20 20 20 20 20 20 20 20 | 20 20 23 20 44 65 66 61 | | # Defa|
|00001c50| 75 6c 74 3a 20 6e 6f 20 | 6e 61 6d 65 20 61 6e 64 |ult: no |name and|
|00001c60| 20 61 64 64 72 65 73 73 | 0d 0d 23 20 45 78 74 72 | address|..# Extr|
|00001c70| 61 63 74 20 6e 61 6d 65 | 20 61 6e 64 20 61 64 64 |act name| and add|
|00001c80| 72 65 73 73 20 66 72 6f | 6d 20 74 68 65 20 66 6f |ress fro|m the fo|
|00001c90| 72 6d 2c 20 69 66 20 67 | 69 76 65 6e 0d 0d 69 66 |rm, if g|iven..if|
|00001ca0| 20 66 6f 72 6d 2e 68 61 | 73 5f 6b 65 79 28 27 4e | form.ha|s_key('N|
|00001cb0| 61 6d 65 27 29 3a 0d 20 | 20 20 20 20 20 20 20 6e |ame'):. | n|
|00001cc0| 61 6d 65 20 3d 20 66 6f | 72 6d 5b 27 4e 61 6d 65 |ame = fo|rm['Name|
|00001cd0| 27 5d 0d 69 66 20 66 6f | 72 6d 2e 68 61 73 5f 6b |'].if fo|rm.has_k|
|00001ce0| 65 79 28 27 41 64 64 72 | 65 73 73 27 29 3a 0d 20 |ey('Addr|ess'):. |
|00001cf0| 20 20 20 20 20 20 20 61 | 64 64 72 20 3d 20 66 6f | a|ddr = fo|
|00001d00| 72 6d 5b 27 41 64 64 72 | 65 73 73 27 5d 0d 20 20 |rm['Addr|ess']. |
|00001d10| 20 20 20 20 20 20 0d 23 | 20 50 72 69 6e 74 20 61 | .#| Print a|
|00001d20| 6e 20 75 6e 6e 75 6d 62 | 65 72 65 64 20 6c 69 73 |n unnumb|ered lis|
|00001d30| 74 20 6f 66 20 74 68 65 | 20 6e 61 6d 65 20 61 6e |t of the| name an|
|00001d40| 64 20 61 64 64 72 65 73 | 73 2c 20 69 66 20 70 72 |d addres|s, if pr|
|00001d50| 65 73 65 6e 74 0d 0d 70 | 72 69 6e 74 20 22 3c 55 |esent..p|rint "<U|
|00001d60| 4c 3e 22 0d 69 66 20 6e | 61 6d 65 20 69 73 20 6e |L>".if n|ame is n|
|00001d70| 6f 74 20 4e 6f 6e 65 3a | 0d 20 20 20 20 20 20 20 |ot None:|. |
|00001d80| 20 70 72 69 6e 74 20 22 | 3c 4c 49 3e 4e 61 6d 65 | print "|<LI>Name|
|00001d90| 3a 22 2c 20 63 67 69 2e | 65 73 63 61 70 65 28 6e |:", cgi.|escape(n|
|00001da0| 61 6d 65 29 0d 69 66 20 | 61 64 64 72 20 69 73 20 |ame).if |addr is |
|00001db0| 6e 6f 74 20 4e 6f 6e 65 | 3a 0d 20 20 20 20 20 20 |not None|:. |
|00001dc0| 20 20 70 72 69 6e 74 20 | 22 3c 4c 49 3e 41 64 64 | print |"<LI>Add|
|00001dd0| 72 65 73 73 3a 22 2c 20 | 63 67 69 2e 65 73 63 61 |ress:", |cgi.esca|
|00001de0| 70 65 28 61 64 64 72 29 | 0d 70 72 69 6e 74 20 22 |pe(addr)|.print "|
|00001df0| 3c 2f 55 4c 3e 22 0d 5c | 65 6e 64 7b 76 65 72 62 |</UL>".\|end{verb|
|00001e00| 61 74 69 6d 7d 0d 0d 54 | 68 65 20 73 63 72 69 70 |atim}..T|he scrip|
|00001e10| 74 20 73 68 6f 75 6c 64 | 20 62 65 20 6d 61 64 65 |t should| be made|
|00001e20| 20 65 78 65 63 75 74 61 | 62 6c 65 20 28 5c 73 61 | executa|ble (\sa|
|00001e30| 6d 70 7b 63 68 6d 6f 64 | 20 2b 78 20 5c 76 61 72 |mp{chmod| +x \var|
|00001e40| 7b 73 63 72 69 70 74 7d | 7d 29 2e 0d 49 66 20 74 |{script}|})..If t|
|00001e50| 68 65 20 50 79 74 68 6f | 6e 20 69 6e 74 65 72 70 |he Pytho|n interp|
|00001e60| 72 65 74 65 72 20 69 73 | 20 6e 6f 74 20 6c 6f 63 |reter is| not loc|
|00001e70| 61 74 65 64 20 61 74 0d | 5c 66 69 6c 65 7b 2f 75 |ated at.|\file{/u|
|00001e80| 73 72 2f 6c 6f 63 61 6c | 2f 62 69 6e 2f 70 79 74 |sr/local|/bin/pyt|
|00001e90| 68 6f 6e 7d 20 62 75 74 | 20 73 6f 6d 65 77 68 65 |hon} but| somewhe|
|00001ea0| 72 65 20 65 6c 73 65 2c | 20 74 68 65 20 66 69 72 |re else,| the fir|
|00001eb0| 73 74 20 6c 69 6e 65 20 | 6f 66 20 74 68 65 0d 73 |st line |of the.s|
|00001ec0| 63 72 69 70 74 20 73 68 | 6f 75 6c 64 20 62 65 20 |cript sh|ould be |
|00001ed0| 6d 6f 64 69 66 69 65 64 | 20 61 63 63 6f 72 64 69 |modified| accordi|
|00001ee0| 6e 67 6c 79 2e 0d 0d 4e | 6f 77 20 74 68 61 74 20 |ngly...N|ow that |
|00001ef0| 65 76 65 72 79 74 68 69 | 6e 67 20 69 73 20 69 6e |everythi|ng is in|
|00001f00| 73 74 61 6c 6c 65 64 20 | 63 6f 72 72 65 63 74 6c |stalled |correctl|
|00001f10| 79 2c 20 77 65 20 63 61 | 6e 20 74 72 79 20 6f 75 |y, we ca|n try ou|
|00001f20| 74 20 74 68 65 20 66 6f | 72 6d 2e 0d 42 72 69 6e |t the fo|rm..Brin|
|00001f30| 67 20 75 70 20 74 68 65 | 20 74 65 73 74 20 66 6f |g up the| test fo|
|00001f40| 72 6d 20 69 6e 20 79 6f | 75 72 20 57 57 57 20 62 |rm in yo|ur WWW b|
|00001f50| 72 6f 77 73 65 72 2c 20 | 66 69 6c 6c 20 69 6e 20 |rowser, |fill in |
|00001f60| 61 20 6e 61 6d 65 20 61 | 6e 64 20 61 64 64 72 65 |a name a|nd addre|
|00001f70| 73 73 0d 69 6e 20 74 68 | 65 20 66 6f 72 6d 2c 20 |ss.in th|e form, |
|00001f80| 61 6e 64 20 70 72 65 73 | 73 20 74 68 65 20 60 60 |and pres|s the ``|
|00001f90| 73 75 62 6d 69 74 27 27 | 20 62 75 74 74 6f 6e 2e |submit''| button.|
|00001fa0| 20 20 54 68 65 20 73 63 | 72 69 70 74 20 73 68 6f | The sc|ript sho|
|00001fb0| 75 6c 64 20 6e 6f 77 0d | 72 75 6e 20 61 6e 64 20 |uld now.|run and |
|00001fc0| 69 74 73 20 6f 75 74 70 | 75 74 20 69 73 20 73 65 |its outp|ut is se|
|00001fd0| 6e 74 20 62 61 63 6b 20 | 74 6f 20 79 6f 75 72 20 |nt back |to your |
|00001fe0| 62 72 6f 77 73 65 72 2e | 20 20 54 68 69 73 20 73 |browser.| This s|
|00001ff0| 68 6f 75 6c 64 20 72 6f | 75 67 68 6c 79 0d 6c 6f |hould ro|ughly.lo|
|00002000| 6f 6b 20 61 73 20 66 6f | 6c 6c 6f 77 73 3a 0d 0d |ok as fo|llows:..|
|00002010| 5c 73 74 72 6f 6e 67 7b | 54 65 73 74 20 46 6f 72 |\strong{|Test For|
|00002020| 6d 20 4f 75 74 70 75 74 | 7d 0d 0d 5c 62 65 67 69 |m Output|}..\begi|
|00002030| 6e 7b 69 74 65 6d 69 7a | 65 7d 0d 5c 69 74 65 6d |n{itemiz|e}.\item|
|00002040| 20 4e 61 6d 65 3a 20 5c | 76 61 72 7b 74 68 65 20 | Name: \|var{the |
|00002050| 6e 61 6d 65 20 79 6f 75 | 20 65 6e 74 65 72 65 64 |name you| entered|
|00002060| 7d 0d 5c 69 74 65 6d 20 | 41 64 64 72 65 73 73 3a |}.\item |Address:|
|00002070| 20 5c 76 61 72 7b 74 68 | 65 20 61 64 64 72 65 73 | \var{th|e addres|
|00002080| 73 20 79 6f 75 20 65 6e | 74 65 72 65 64 7d 0d 5c |s you en|tered}.\|
|00002090| 65 6e 64 7b 69 74 65 6d | 69 7a 65 7d 0d 0d 49 66 |end{item|ize}..If|
|000020a0| 20 79 6f 75 20 64 69 64 | 6e 27 74 20 65 6e 74 65 | you did|n't ente|
|000020b0| 72 20 61 20 6e 61 6d 65 | 20 6f 72 20 61 64 64 72 |r a name| or addr|
|000020c0| 65 73 73 2c 20 74 68 65 | 20 63 6f 72 72 65 73 70 |ess, the| corresp|
|000020d0| 6f 6e 64 69 6e 67 20 6c | 69 6e 65 20 77 69 6c 6c |onding l|ine will|
|000020e0| 20 62 65 0d 6d 69 73 73 | 69 6e 67 20 28 73 69 6e | be.miss|ing (sin|
|000020f0| 63 65 20 74 68 65 20 62 | 72 6f 77 73 65 72 20 64 |ce the b|rowser d|
|00002100| 6f 65 73 6e 27 74 20 73 | 65 6e 64 20 65 6d 70 74 |oesn't s|end empt|
|00002110| 79 20 66 6f 72 6d 20 66 | 69 65 6c 64 73 20 74 6f |y form f|ields to|
|00002120| 20 74 68 65 0d 73 65 72 | 76 65 72 29 2e 0d | the.ser|ver).. |
+--------+-------------------------+-------------------------+--------+--------+